package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Statefile;
import com.ruoyi.system.service.IStatefileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 静态资源Controller
 * 
 * @author ç¹è½æ²
 * @date 2025-05-06
 */
@RestController
@RequestMapping("/statefile/statefile")
public class StatefileController extends BaseController
{
    @Autowired
    private IStatefileService statefileService;

    /**
     * 查询静态资源列表
     */
    @PreAuthorize("@ss.hasPermi('statefile:statefile:list')")
    @GetMapping("/list")
    public TableDataInfo list(Statefile statefile)
    {
        startPage();
        List<Statefile> list = statefileService.selectStatefileList(statefile);
        return getDataTable(list);
    }

    /**
     * 导出静态资源列表
     */
    @PreAuthorize("@ss.hasPermi('statefile:statefile:export')")
    @Log(title = "静态资源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Statefile statefile)
    {
        List<Statefile> list = statefileService.selectStatefileList(statefile);
        ExcelUtil<Statefile> util = new ExcelUtil<Statefile>(Statefile.class);
        util.exportExcel(response, list, "静态资源数据");
    }

    /**
     * 获取静态资源详细信息
     */
    @PreAuthorize("@ss.hasPermi('statefile:statefile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(statefileService.selectStatefileById(id));
    }

    /**
     * 新增静态资源
     */
    @PreAuthorize("@ss.hasPermi('statefile:statefile:add')")
    @Log(title = "静态资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Statefile statefile)
    {
        return toAjax(statefileService.insertStatefile(statefile));
    }

    /**
     * 修改静态资源
     */
    @PreAuthorize("@ss.hasPermi('statefile:statefile:edit')")
    @Log(title = "静态资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Statefile statefile)
    {
        return toAjax(statefileService.updateStatefile(statefile));
    }

    /**
     * 删除静态资源
     */
    @PreAuthorize("@ss.hasPermi('statefile:statefile:remove')")
    @Log(title = "静态资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(statefileService.deleteStatefileByIds(ids));
    }
}
